import math
import matplotlib.pyplot as plt

# 常量设置
div_weight = 1.0
total_epochs = 300

# 存储每个epoch的进度和动态权重
epochs = []
progress_values = []
dynamic_weights = []

for epoch in range(total_epochs):
    progress = epoch / total_epochs
    dynamic_weight = div_weight * 0.5 * (1 + math.cos(math.pi * progress))
    
    epochs.append(epoch)
    progress_values.append(progress)
    dynamic_weights.append(dynamic_weight)

# 绘制结果
plt.figure(figsize=(14, 7))

# 进度图
plt.subplot(1, 2, 1)
plt.plot(epochs, progress_values, label='Progress')
plt.title('Training Progress')
plt.xlabel('Epoch')
plt.ylabel('Progress')
plt.legend()

# 动态权重图
plt.subplot(1, 2, 2)
plt.plot(epochs, dynamic_weights, label='Dynamic Weight', color='orange')
plt.title('Dynamic Weight Over Time')
plt.xlabel('Epoch')
plt.ylabel('Weight')
plt.legend()

plt.tight_layout()
plt.show()